<?php
/**
 * Created by PhpStorm.
 * User: asus
 * Date: 2017/9/20
 * Time: 15:01
 */

namespace Wechat\Controller;

//俱乐部控制器
class ClubController extends CommonController
{
    //主页
    public function index()
    {
        //1为资讯 2为干货 3为搞笑
        $zixun = M('happy')->where(['type'=>1])->order('sort desc')->select();
        $baike = M('happy')->where(['type'=>2])->order('sort desc')->select();
        $shangxueyuan = M('happy')->where(['type'=>3])->order('sort desc')->select();

        $this->assign(
            [
                'zixun'=>$zixun,
                'baike'=>$baike,
                'shangxueyuan'=>$shangxueyuan,
            ]
        );
        $this->display();
    }
    //详情页
    public function content()
    {
        $id = i('get.id');
        $url = $_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
        (new WechatController())->zidingfenxiang($url);
        $data = M('happy')->where(['id'=>$id])->find();
        //阅读量+1
        $save = $data['read']+1;
        M('happy')->where(['id'=>$id])->save(['read'=>$save]);
        $this->assign(['vo'=>$data]);
        $this->display();
    }
}